package com.hgnu.dorm.mapper;


import com.hgnu.dorm.domain.dto.UserPageQueryDto;
import com.hgnu.dorm.domain.po.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper {
    @Select("select * from dorm.user where account=#{account} and password = #{password} and status != 0")
    User login(User user);

    @Select("select * from dorm.user where account=#{account}")
    User findByAccount(String account);

    //根据条件查询总共有多少个用户
    Long count(UserPageQueryDto dto);

    //根据条件查询用户列表
    List<User> page(UserPageQueryDto dto);
    // 根据id查询用户
    @Select("select id, account, create_time, update_time, role_id, status from dorm.user where id=#{id}")
    User getById(Integer id);

    int deleteUserByIds(Long[] ids);

    void insertUser(User user);

    void updateUser(User user);

    Integer countStatus(Long[] ids);

    //根据id查询用户
    @Select("select id, account, create_time, update_time, role_id, status from dorm.user where id=#{id}")
    User findById(Long id);
}
